package controller.gui.mapmenu;

import java.awt.event.ActionEvent;

import javax.swing.JButton;

import advance.GameMap;

import tool.dialog.JField;
import gui.secondary.MapSecondaryMenu;
import controller.Controller;
import controller.NullStaticObjectException;
import controller.gui.OKButtonController;
import errors.DimensionNotAcceptableException;
import errors.WidthNotAcceptableException;

/**rappresenta il Controller che pilota il pulsatne di conferma all'interno del menu' secondario
 * di gestione proprieta' generali della mappa.
 * 
 * @author Koldar
 * @version 1.1
 *
 */
public class MapPropertiesOKController extends OKButtonController<MapSecondaryMenu>{
	
	public MapPropertiesOKController(JButton button,MapSecondaryMenu _superpanel) {
		super(button,_superpanel);
	}
	

	@Override
	public void executeOtherInstruction(ActionEvent arg0) {
		super.executeOtherInstruction(arg0);
		currentmap.setWidth(this.superPanel.getWidthJTextField().getValue());
		currentmap.setHeight(this.superPanel.getHeightJTextField().getValue());
		currentmap.setMapresolution(this.superPanel.getStepJTextField().getValue());
		currentmap.setTitle(this.superPanel.getTitleJTextField().getValue());
	}

	@Override
	public boolean isParametersCorrect() {
		return (this.superPanel.getWidthJTextField().getState()==JField.CORRECT)&&
				(this.superPanel.getHeightJTextField().getState()==JField.CORRECT)&&
				(this.superPanel.getStepJTextField().getState()==JField.CORRECT)&&
				(this.superPanel.getTitleJTextField().getState()==JField.CORRECT);
	}

}
